package wrappers;

import entities.Country;
import java.util.*;

/**
 *
 * @author KAV
 */
public class CountryWrap extends AbstractWrap{
    private Country e;

    public CountryWrap(Country _e){
        e=_e;
    }

    public ViewElement getViewId() {
        return new ViewElement("id",Integer.toString(e.getId()));
    }
    public ViewElement getViewTitle() {
        return new ViewElement("title", e.getTitle());
    }

    @Override
    public int compareTo(Object o) {
        int result = 0;
        CountryWrap ew = (CountryWrap) o;
        switch(compareCase) {
            case 0: result = (isAscending) ? (this.e.getId() - ew.e.getId()) : (ew.e.getId() - this.e.getId());break;
            case 1: result = (isAscending) ? (this.e.getTitle().compareTo(ew.e.getTitle())) : (ew.e.getTitle().compareTo(this.e.getTitle()));break;
        }
        return result;
    }

    @Override
    public List<String> getHeaders() {
        List<String> headers = new LinkedList<String>();
        headers.add(getViewId().getHeader());
        headers.add(getViewTitle().getHeader());
        return headers;
    }

    @Override
    public List<String> getCells() {
        List<String> cells = new LinkedList<String>();
        cells.add(getViewId().toString());
        cells.add(getViewTitle().toString());
        return cells;
    }

    @Override
    public String getPrimaryKey() {
        return getViewId().toString();
    }
}
